/*
 * @Author: hyq
 * @LastEditors: hyq
 * @Description: useCustomHeader
 * @Date: 2023-12-05 11:04:46
 */
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { isMpWeixin, isMpBaidu } from '@/utils'

export function useCustomHeader() {
  const statusBarHeight = ref<number>(20)
  const contentBarHeight = ref<number>(40)
  if (isMpWeixin || isMpBaidu) {
    onLoad(() => {
      const area = uni.getSystemInfoSync()
      const menu = uni.getMenuButtonBoundingClientRect()
      statusBarHeight.value = area.statusBarHeight!

      contentBarHeight.value = area.statusBarHeight
        ? menu.height + (menu.top - area.statusBarHeight!) * 2
        : isMpBaidu
        ? 60
        : 40
    })
  }
  return {
    statusBarHeight,
    contentBarHeight
  }
}
